package cn.felord.reactor.flux.factory;

import org.springframework.beans.factory.FactoryBean;

/**
 * @author Dax
 * @since 22:00  2019-08-10
 */
public class TaskFactoryBean implements FactoryBean<Task> {
    private SomeService someService;
    private String cronExpression;


    @Override
    public Task getObject() throws Exception {
        CustomTask customTask = new CustomTask(someService);
        customTask.setCron(cronExpression);
        return customTask;
    }

    @Override
    public Class<?> getObjectType() {
        return CustomTask.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }

    public SomeService getSomeService() {
        return someService;
    }

    public void setSomeService(SomeService someService) {
        this.someService = someService;
    }

    public String getCronExpression() {
        return cronExpression;
    }

    public void setCronExpression(String cronExpression) {
        this.cronExpression = cronExpression;
    }
}
